package com.bwie.redis;

import com.bwie.mapper.TbNetworkMapper;
import com.bwie.mapper.TbReportMapper;
import com.bwie.pojo.TbReport;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.StringRedisTemplate;

import javax.annotation.Resource;
import java.util.List;
import java.util.concurrent.TimeUnit;

@Configuration
public class Redis implements ApplicationRunner {
    @Resource
    TbReportMapper tbReportMapper;

    @Resource
    StringRedisTemplate stringRedisTemplate;

    @Override
    public void run(ApplicationArguments args) throws Exception {
        List<TbReport> tbReports = tbReportMapper.selectList(null);
        String ReportKey = "上报列表数据-";
        stringRedisTemplate.opsForValue().set(ReportKey,tbReports.toString(),5, TimeUnit.MINUTES);

    }
}
